package com.ubs.training.web.util;

import com.ubs.training.server.dao.model.Client;
import org.springframework.util.StringUtils;
import org.springframework.validation.Errors;

/**
 * Created with IntelliJ IDEA.
 * User: xubuntu
 * Date: 8/22/12
 * Time: 9:10 AM
 * To change this template use File | Settings | File Templates.
 */
public class ClientValidator {
    private Client client;
    private Errors res;

    public ClientValidator(Client client, Errors res) {
        this.client = client;
        this.res = res;

    }

    public void validate() {
        if (!StringUtils.hasLength(client.getFname())) {
            res.rejectValue("fname", "empty");
        }
        if (!StringUtils.hasLength(client.getLname())) {
            res.rejectValue("lname", "empty");
        }
    }
}
